package xin.zhiyin.控制.system.系统;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import xin.zhiyin.实体.阿里云OSS配置信息Entity;
import xin.zhiyin.工具.ResponseBo;
import xin.zhiyin.服务.系统.阿里云OSS配置信息Service;

@Controller
@RequestMapping(path = "/system/config/upload")//页面的url地址
public class 文件存储配置Controller {
    @Autowired
    private 阿里云OSS配置信息Service 云Service;
    @GetMapping(path = "/setting")
    public String 后台首页(Model model){
        model.addAttribute("yunOSS",云Service.根据id获取阿里云OSS(1));
        return "system/config/upload/setting";
    }

    /* 添加OSS配置信息 */
    @RequestMapping("/addALiYunOSS")
    public String 添加阿里云OSS() {
        阿里云OSS配置信息Entity oss =new 阿里云OSS配置信息Entity();
        oss.setName("阿里云OSS");
        oss.setKeyId("LTAI5tSH1d1i6FbaJBE57uas722");
        oss.setKeySecret("uoHVJKazpU7jSkbzU6c8lLW5EpzXrH722");
        oss.setEndPoint("oss-cn-hangzhou.aliyuncs.com");
        oss.setBucketName("880-oss");
        System.out.println(oss.getName()+"+++++++++++++++");
        云Service.保存(oss);
        return "";
    }
    @RequestMapping("/getYunOSSById")
    @ResponseBody
    public ResponseBo 根据id获取阿里云OSS配置信息(Integer aLiYunOSSId)
    {
        阿里云OSS配置信息Entity aLiYunOSS = 云Service.根据id获取阿里云OSS(aLiYunOSSId);

        return ResponseBo.ok(aLiYunOSS);
    }
}
